#include <string>
#include <vector>
using namespace std;
/*
 * @lc app=leetcode.cn id=345 lang=cpp
 *
 * [345] 反转字符串中的元音字母
 */

// @lc code=start
class Solution {
public:
    bool is(char x) {
        return x == 'a' || x == 'e' || x == 'i' || x == 'o'
            || x == 'u' || x == 'A' || x == 'E' || x == 'I'
            || x == 'O' || x == 'U';
    };

    string reverseVowels(string s) {
        int i = 0, j = s.size() - 1;
        char t;
        while (i < j) {
            if (is(s[i]) && is(s[j])) {
                t = s[i]; s[i] = s[j]; s[j] = t;
                i++; j--;
            }
            else if (!is(s[i])) i++;
            else if (!is(s[j])) j--;
        }
        return s;
    }
};
// @lc code=end

